<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<!-- viewport 后面加上 minimal-ui 在safri 体现效果 -->
		<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0,minimal-ui"/>
		<meta name="apple-mobile-web-app-capable" content="yes" />		<!-- iphone safri 全屏 -->
		<meta name="apple-mobile-web-app-status-bar-style" content="black" />	<!-- iphone safri 状态栏的背景颜色 -->
		<meta name="apple-mobile-web-app-title" content="搬砖之王">		<!-- iphone safri 添加到主屏界面的显示标题 -->
		<meta name="format-detection" content="telphone=no, email=no" />	<!-- 禁止数字识自动别为电话号码 -->
		<meta name="renderer" content="webkit">				<!-- 启用360浏览器的极速模式(webkit) -->
		<meta http-equiv="X-UA-Compatible" content="IE=edge">
		<meta name="HandheldFriendly" content="true">		<!-- 是针对一些老的不识别viewport的浏览器，列如黑莓 -->
		<meta name="MobileOptimized" content="320">			<!-- 微软的老式浏览器 -->
		<meta http-equiv="Cache-Control" content="no-siteapp" />	<!-- 禁止百度转码 -->
		<meta name="screen-orientation" content="portrait">	<!-- UC强制竖屏 -->
		<meta name="browsermode" content="application">		<!-- UC应用模式 -->
		<meta name="full-screen" content="yes">				<!-- UC强制全屏 -->
		<meta name="x5-orientation" content="portrait">		<!-- QQ强制竖屏 -->
		<meta name="x5-fullscreen" content="true">			<!-- QQ强制全屏 -->
		<meta name="x5-page-mode" content="app">
		<title>入口1页面</title>
		<link rel="stylesheet" type="text/css" href="css/public.css"/>
		<style type="text/css">
			p {
				line-height: 80vh;
				text-align: center;
			}
		</style>
		<script src="js/public.js" type="text/javascript" charset="utf-8"></script>
	</head>
	<body>
		<div class="zone">
			<p id="step">正在打开软件</p>
		</div>
		<script>
			onload = () => {
				console.log('当前线路：'+location.href);
				let step = $('#step');
				step.innerText = '检查版本信息'
				// 检查版本
				ajax({
					url: API_PATH.CHECK_VERSION,
					data: {
						client_version: '1.0'
					},
					success: res => {
						step.innerText = '检查登录状态';
						let server_version = res.data;
						// 检查登录
						let token = getCookie('token');
						let userid = getCookie('userid');
						if (!token) location.replace('page/login.html');
						else {
							ajax({
								url: API_PATH.USER_INFO,
								header: {
									'king-token': token,
									'king-id': userid
								},
								success: (res) => {
									if (res.code != 1) {
										step.innerText = '登录信息失效，跳转到登录页';
										location.replace('page/login.html');
									}
									else {
										step.innerText = '登录成功，正在跳转';
										location.replace('page/home.html?v='+server_version);
									}
								},
								error: err => {
									console.log(err);
									step.innerText = '登录失败';
								}
							});
						}
					},
					error: err => {
						step.innerText = '获取版本信息失败';
					}
				});
				
			}
		</script>
	</body>
</html>
